﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace TPTecnicas.Common
{
	public class Utils
	{
		public static void SaveMailAttachment(System.Net.Mail.Attachment attachment)
		{
			byte[] allBytes = new byte[attachment.ContentStream.Length];
			int bytesRead = attachment.ContentStream.Read(allBytes, 0, (int)attachment.ContentStream.Length);

			string destinationFile = attachment.Name;

			BinaryWriter writer = new BinaryWriter(new FileStream(destinationFile, FileMode.OpenOrCreate, FileAccess.Write, FileShare.None));
			writer.Write(allBytes);
			writer.Close();
		}
	}
}
